<template>
  <div class="body">
    <!-- 标题 -->
    <v-head></v-head>
    <Row class="restand">
    <i-col class="standkepudigndan" span="17">
      <div class="standardt">
        知识法规
      </div>
      <div class="result">
        <Row class="knowledge">
            <!-- <i-col span="12">
              <span class="conditioninputitle">标准号</span>
              <Input v-model="ssnum" placeholder="请输入标准号" class="conditioninpu" />
            </i-col> -->
            <i-col span="6">
              <span class="conditioninputitle">题名</span>
              <Input v-model="title" placeholder="请输入题名" class="conditioninpu" />
            </i-col>
            <i-col span="6" class="kwdtj">
              <span class="conditioninputitle">国家</span>
             <Select v-model="nationcode" style="width:200px">
                <Option v-for="item in cityList" :value="item.Abbreviation" :key="item.value">{{ item.Name }}</Option>
            </Select>
            </i-col>
            <i-col span="6" class="kwdtj">
              <span class="conditioninputitle">行业</span>
              <Select v-model="industrycode" style="width:200px">
                  <Option v-for="item in industryList" :value="item.Abbreviation" :key="item.value">{{ item.Name }}</Option>
              </Select>
            </i-col>
            <i-col span="2" class="kwdtj">
              <Button class="searchbutton" type="success" v-on:click="getNewlistfg()">检索</Button>
            </i-col>
        </Row>
        <Row class="orderrow" v-for="(item,index) in resultsfagui" :key="index">
          <i-col span="1">
            <div class="orderimg" alt=""></div>
          </i-col>
          <i-col span="20">
            <span @click="getDetailK(item.id)" class="itemtitle">{{item.title}}</span>
          </i-col>
          <i-col span="2">
            <div  class="itemtitledate">{{item.createDate.substring(0,10)}}</div>
          </i-col>
        </Row>
        <Page :total="dataCountfg" :page-size="pageSizefg" show-total @on-change="changepage" v-if="showPagefg" class-name="changepage" show-elevator />
      </div>
    </i-col>
    </Row>
        <Row class="restand">
    <i-col class="standkepudigndan" span="17">
      <div class="standardt">
        知识库
      </div>
      <div class="result">
        <Row class="orderrow" v-for="(item,index) in results" :key="index">
          <i-col span="1">
            <div class="orderimg" alt=""></div>
          </i-col>
          <i-col span="20">
            <span @click="getDetail(item.id)" class="itemtitle">{{item.title}}</span>
          </i-col>
          <i-col span="2">
            <div  class="itemtitledate">{{item.createDate.substring(0,10)}}</div>
          </i-col>
        </Row>
        <Page :total="dataCount" :page-size="pageSize" show-total @on-change="changepagefg" v-if="showPage" class-name="changepage" show-elevator />
      </div>
    </i-col>
    </Row>
    <!-- 底部 -->
    <v-foot></v-foot>
    <Back-top></Back-top>
  </div>
</template>
<script>
import {neturl} from '../assets/js/common'
export default {
  name: 'seniorsearch',
  data () {
    return {
      keyword: '',
      dataCount: 0,
      pageSize: 15,
      pageNum: 1,
      showPage: false,
      results: [],
      dataCountfg: 0,
      pageSizefg: 15,
      pageNumfg: 1,
      showPagefg: false,
      resultsfagui: [],
      cityList: [],
      industryList: [],
      nationcode: '',
      industrycode: '',
      title: ''
    }
  },
  methods: {
    // 获取国家分类
    getNationlist () {
      let uploadcc = { data: '' }
      this.$axios.post(neturl + '/by/knowledge/getnation', uploadcc
      ).then(res => {
        // console.log(res)
        this.cityList = res.data.data.result
      })
    },
    // 获取行业分类
    getIndustrylist () {
      let uploadcc = { data: '' }
      this.$axios.post(neturl + '/by/knowledge/getindustry', uploadcc
      ).then(res => {
        // console.log(res)
        this.industryList = res.data.data.result
      })
    },
    // 获取知识法规列表
    getNewlistfg () {
      let uploadcc = { data: '{page: ' + this.pageNumfg + ', pagesize: ' + this.pageSizefg + ', nationcode: ' + this.nationcode + ', industrycode: ' + this.industrycode + ', title:"' + this.title + '"}' }
      this.$axios.post(neturl + '/by/knowledge/getkonwledge', uploadcc
      ).then(res => {
        // console.log(res)
        this.resultsfagui = res.data.data.result
        this.dataCountfg = res.data.data.records
        this.showPagefg = true
        this.$Spin.hide()
      })
    },
    // 获取新闻列表
    getNewlist () {
      let uploadcc = { data: '{page: ' + this.pageNum + ', pagesize: ' + this.pageSize + ', cateid:"494b2576-c94b-482a-bd07-1898208a479c"}' }
      this.$axios.post(neturl + '/by/knowledge/getlist', uploadcc
      ).then(res => {
        // console.log(res)
        this.results = res.data.data.result
        this.dataCount = res.data.data.records
        this.showPage = true
        this.$Spin.hide()
      })
    },
    logout () {
      this.$cookie.delete('user')
      let routeUrl = this.$router.resolve({
        path: '/'
      })
      window.open(routeUrl.href)
    },
    changepage (value) {
      this.pageNum = value
      this.getNewlist()
    },
    changepagefg (value) {
      this.pageNumfg = value
      this.getNewlistfg()
    },
    getDetail (id) {
      let routeData = this.$router.resolve({path: '/knowledgeitem', query: {id: id}})
      window.open(routeData.href, '_self')
    },
    getDetailK (id) {
      let routeData = this.$router.resolve({path: '/knowledgefg', query: {id: id}})
      window.open(routeData.href, '_self')
    }
  },
  created () {
    this.$Spin.show()
    // console.log(111)
    // this.model1 = this.cityList[0].value
    this.userinfo = this.$cookie.get('user')
    this.userinfo = JSON.parse(this.userinfo)
    // 已登录
    if (this.userinfo != null) {
      this.islogin = true
      this.islog = false
      this.username = this.userinfo.realName
    }
    this.getNewlist()
    this.getNewlistfg()
    this.getNationlist()
    this.getIndustrylist()
  }
}
</script>

<style scoped>
  @import '../assets/css/knowledgelist.css';
</style>
